// time.cpp : implementation file
//

#include "stdafx.h"
#include "MyDX.h"
#include "time.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// time dialog


time::time(CWnd* pParent /*=NULL*/)
	: CDialog(time::IDD, pParent)
{
	//{{AFX_DATA_INIT(time)
	m_min = 0;
	m_sec = 0;
	m_mon = 0;
	m_day = 0;
	m_year = 0;
	m_hour = 0;
	//}}AFX_DATA_INIT
}


void time::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(time)
	DDX_Control(pDX, IDC_EDIT6, m_Cday);
	DDX_Control(pDX, IDC_EDIT5, m_Cmon);
	DDX_Control(pDX, IDC_EDIT4, m_Cyear);
	DDX_Control(pDX, IDC_EDIT3, m_Csec);
	DDX_Control(pDX, IDC_EDIT2, m_Cmin);
	DDX_Control(pDX, IDC_EDIT1, m_Chour);
	DDX_Text(pDX, IDC_EDIT2, m_min);
	DDV_MinMaxInt(pDX, m_min, 0, 59);
	DDX_Text(pDX, IDC_EDIT3, m_sec);
	DDV_MinMaxInt(pDX, m_sec, 0, 59);
	DDX_Text(pDX, IDC_EDIT5, m_mon);
	DDV_MinMaxInt(pDX, m_mon, 1, 12);
	DDX_Text(pDX, IDC_EDIT6, m_day);
	DDV_MinMaxInt(pDX, m_day, 1, 31);
	DDX_Text(pDX, IDC_EDIT4, m_year);
	DDV_MinMaxInt(pDX, m_year, 0, 3000);
	DDX_Text(pDX, IDC_EDIT1, m_hour);
	DDV_MinMaxInt(pDX, m_hour, 0, 24);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(time, CDialog)
	//{{AFX_MSG_MAP(time)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON10, OnButton0)
	ON_BN_CLICKED(IDC_BUTTON11, OnButtonBackSpace)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
	ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
	ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
	ON_EN_SETFOCUS(IDC_EDIT2, OnSetfocusEdit2)
	ON_EN_SETFOCUS(IDC_EDIT3, OnSetfocusEdit3)
	ON_EN_SETFOCUS(IDC_EDIT4, OnSetfocusEdit4)
	ON_EN_SETFOCUS(IDC_EDIT5, OnSetfocusEdit5)
	ON_EN_SETFOCUS(IDC_EDIT6, OnSetfocusEdit6)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// time message handlers

void time::OnButton1() 
{
	// TODO: Add your control notification handler code here
   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+1;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+1;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+1;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+1;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+1;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+1;
			break;
	}
   UpdateData(FALSE);
}

void time::OnButton0() 
{
	// TODO: Add your control notification handler code here
	switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10;
			break;
		case IDC_EDIT2:
			m_min=m_min*10;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10;
			break;
		case IDC_EDIT4:
			m_year=m_year*10;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10;
			break;
		case IDC_EDIT6:
			m_day=m_day*10;
			break;
	}
	UpdateData(FALSE);
}

void time::OnButtonBackSpace() 
{
	// TODO: Add your control notification handler code here
	switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour/10;
			break;
		case IDC_EDIT2:
			m_min=m_min/10;
			break;
		case IDC_EDIT3:
			m_sec=m_sec/10;
			break;
		case IDC_EDIT4:
			m_year=m_year/10;
			break;
		case IDC_EDIT5:
			m_mon=m_mon/10;
			break;
		case IDC_EDIT6:
			m_day=m_day/10;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton2() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+2;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+2;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+2;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+2;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+2;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+2;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton3() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+3;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+3;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+3;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+3;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+3;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+3;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton4() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+4;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+4;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+4;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+4;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+4;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+4;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton5() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+5;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+5;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+5;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+5;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+5;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+5;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton6() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+6;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+6;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+6;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+6;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+6;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+6;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton7() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+7;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+7;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+7;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+7;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+7;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+7;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton8() 
{
	// TODO: Add your control notification handler code here
	   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+8;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+8;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+8;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+8;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+8;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+8;
			break;
	}
	   UpdateData(FALSE);
}

void time::OnButton9() 
{
	// TODO: Add your control notification handler code here
   switch (m_using->GetDlgCtrlID())
	{	case IDC_EDIT1:
			m_hour=m_hour*10+9;
			break;
		case IDC_EDIT2:
			m_min=m_min*10+9;
			break;
		case IDC_EDIT3:
			m_sec=m_sec*10+9;
			break;
		case IDC_EDIT4:
			m_year=m_year*10+9;
			break;
		case IDC_EDIT5:
			m_mon=m_mon*10+9;
			break;
		case IDC_EDIT6:
			m_day=m_day*10+9;
			break;
	}	
   UpdateData(FALSE);
}

void time::OnSetfocusEdit1() 
{
	// TODO: Add your control notification handler code here
	m_using=&m_Chour;
}

void time::OnSetfocusEdit2() 
{
	// TODO: Add your control notification handler code here
    m_using=&m_Cmin;	
}

void time::OnSetfocusEdit3() 
{
	// TODO: Add your control notification handler code here
	m_using=&m_Csec;
}

void time::OnSetfocusEdit4() 
{
	// TODO: Add your control notification handler code here
	m_using=&m_Cyear;
}

void time::OnSetfocusEdit5() 
{
	// TODO: Add your control notification handler code here
	m_using=&m_Cmon;
}

void time::OnSetfocusEdit6() 
{
	// TODO: Add your control notification handler code here
	m_using=&m_Cday;
}
